<?php
session_start();
?>
<html>
	<head>
	<LINK rev="stylesheet" media="screen" href="cssadmin.css" type="text/css" 
rel="stylesheet">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
	</head>
	
<a href='admin_login.php?action=logout'>退出登录</a>
<script language="javascript">
	function con()
	{
		if(window.confirm('确认要删除吗？'))
		{
			alert('删除成功');
		}
		else
		{
			return false;
		}
	}
</script>
<?php
	include ('include/config.php');
	
	include ('include/conn.php');
	include ('include/session.php');
	$everypage = 4 ; 
	$pagecount = "SELECT COUNT(*) FROM tab";
	$pageres=mysql_query($pagecount);
	$pagetotal=mysql_result($pageres,0,0);
	$pagenum=$pagetotal/$everypage;
	$pagenum=ceil($pagenum);
	$pagenow=1;
		
		if(isset($_GET['page']) && $_GET['page'] )
			{ 
				$pagenow = intval($_GET['page']);
			
			}
	$nextpage=$pagenow+1;
		if($nextpage>=$pagenum)
		{
			$nextpage=$pagenum;
		}
		$prepage=$pagenow-1;
		if($prepage <1)
		{
			$prepage = 1;
		}
	$start =$everypage*( $pagenow-1);
	?>
	
	
	<?php
				
				
				echo	<<<cont
		一共有${pagetotal}条留言，每页显示 ${everypage}条，共${pagenum}页，当前第${pagenow}页  
		<br>
<a href="?page=1">
		|<<首页 
		</a>
		<a href="?page=${prepage}">
		<<上页 
		</a>
		<a href="?page=${nextpage}">
		下页>> 
		</a>
		<a href="?page=${pagenum}">
		尾页>>|
		</a>
cont;

		
		$sel="SELECT id,content,name,qq,time,ip FROM tab ORDER BY time DESC LIMIT $start, $everypage";
		$a=mysql_query($sel);
		while($i=mysql_fetch_object($a))
		{		
			echo "<div class='admin'>";
				echo "<div>主题：$i->content</div>";
				echo "<div>昵称：$i->name</div>";
				echo "<div>QQ：$i->qq</div>";
				echo "<div>留言时间：$i->time</div>";
				echo "<div>IP：$i->ip</div>";
				echo "<a onclick='return con()' href=deletemsg.php?id=$i->id >删除</a>";
				echo "<a href=editmsg_index.php?id=$i->id > 修改</a>";
			echo "</div>";
		}
	?>
	
</html>